# encoding=utf-8
# 处理接口响应（response）上下文


from common.writeYaml import write_data
from processingContext.replace import ReadYamlRender
from settings.settings import Route


def token_context(result):
    """
    处理token上下文
    :param result: 接口响应值(response)
    :return:
    """
    token = {'token': result['result']['access_token']}

    # 生成下一个接口的请求数据
    next_context = ReadYamlRender(Route().dataModels('query.yaml'), token).render
    # 将请求数据写入 （测试用例）testcase 下的query.yaml文件中
    write_data((Route().testcases('query.yaml')), next_context)

